<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://upbase.com.cn/tags" prefix="shr"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<shr:html>
<shr:header title="${headName}管理"></shr:header>
<script type="text/javascript">
var curSearchInfo;
var url;

$(document).ready(function() {
	AppKit.setSize("grid", 320);
	$(window).resize(function(){
        AppKit.setSize("grid", 320);
    });
	curSearchInfo = $("#searchform").serializeObject();
});

function dosearch() {
	var paramObj = $("#searchform").serializeObject();

	$('#grid').datagrid('load', paramObj);
};

function del() {
	var rowData = AppKit.getRowSelect('#grid');

	if (rowData) {
		AppKit.showConfirmMessage(function() {
			var url = "${r'${path}'}/${tableModel}/${tableAliasFistUpper}Action!del${tableAliasFistUpper}.action?${tablePK}="+ rowData.${tablePK};
			AppKit.postJSON(url, "", delSuccess);
		});
	} else {
		AppKit.showMessage("请选择记录");
	}
}

function delSuccess(json) {
	if (!AppKit.checkJSONResult(json)) {
		return;
	}
	$('#grid').datagrid('deleteRow', AppKit.getRowIndex("#grid"));
	AppKit.showMessage(json.message);
}

function reset() {
		$('#searchform input').each(function() {
			$(this).val(curSearchInfo[$(this).attr('id')]);
		});

		$('#searchform select').each(function() {
			$(this).combobox("setValue", curSearchInfo[$(this).attr('id')]);
		});
	}

	function openadd(){
		var url = "${r'${path}'}/views/jsp/${appName}/${tableModel}/${tableAlias}Add.jsp";
		AppKit.openWindow("detail_modal", url, 540, 200, '新增${headName}信息', $('#grid'));
	}
	function openview(){		
		var rowData = AppKit.getRowSelect('#grid');
		
		if (rowData) {
			var url = "${r'${path}'}/views/jsp/${appName}/${tableModel}/${tableAlias}View.jsp?${tablePK}="+rowData.${tablePK};
			AppKit.openWindow("detail_modal", url,540, 200, '查看${headName}详情', $('#grid'));
		} else {
			AppKit.showMessage("请选择记录");
		}
		
		
	}
	function openedit(){
		var rowData = AppKit.getRowSelect('#grid');
		
		if (rowData) {
			var url = "${r'${path}'}/views/jsp/${appName}/${tableModel}/${tableAlias}Update.jsp?${tablePK}="+rowData.${tablePK};
			AppKit.openWindow("detail_modal", url,540, 200, '更新${headName}信息', $('#grid'));
		} else {
			AppKit.showMessage("请选择记录");
		}
	}	
	 
</script>

<shr:body>
	<div>
		<shr:fieldset title="查询条件">
			<form method="get" id="searchform">
				<table width="100%" border="0" cellspacing="0" cellpadding="0"
					class="viewdatagrid">
					<tr>
						<th style="width: 80px">：</th>
						<td><input type="text" id="" name="" /></td>
					</tr>
					<tr>
						<td colspan="1" class="buttonline"
							style="text-align: center; padding: 10px 0px 10px 0px">
							<a href="javascript:dosearch();" class="search"><span>查找</span>
							</a>
							<a href="javascript:reset();" class="reset"><span>重置</span>
							</a>
						</td>
					</tr>
				</table>
			</form>
		</shr:fieldset>

		<table id="grid" class="easyui-datagrid" toolbar="#toolbar"
			data-options="url:'${r"${path}"}/${tableModel}/${tableAliasFistUpper}Action!query${tableAliasFistUpper}.action' 
				,pagination:true
				,title:'查询结果'
				,rownumbers:true
				,fitColumns:true
				,border: true
				,striped:true
				,singleSelect:true
				,pageSize:20
				,autoRowHeight:true">
			<thead>
				<tr>
					<#list listColumn as column >
						<th field="${column.id}" <#if column.name==tablePK> hidden="true"</#if> <#if column.name!=tablePK> hidden="false"</#if> sortable="true"  align="center">
							${column.label}
						</th>
					</#list>	
				</tr>   
			</thead>
		</table>
	</div>

	<div id="toolbar" style="background: #fafafa; padding: 3px 5px;">
		<a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" style="border: solid 1px #95B8E7;color:blue;font-weight: bold"
			id="addBtn" onclick="javascript:openadd()">新增</a>
		<a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" style="border: solid 1px #95B8E7;color:blue;font-weight: bold"
			onclick="javascript:openedit()">修改</a>
		<a href="#" class="easyui-linkbutton" iconCls="icon-remove" style="border: solid 1px #95B8E7;color:blue;font-weight: bold"
			plain="true" id="delBtn" onclick="javascript:del()">删除</a>
		<a href="#" class="easyui-linkbutton" iconCls="icon-remove" style="border: solid 1px #95B8E7;color:blue;font-weight: bold"
			plain="true" id="delBtn" onclick="javascript:openview()">查看详情</a>
	</div>
</shr:body>
<shr:alertmsg></shr:alertmsg>
</shr:html>